<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script src="../js/interface.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .list {
            width: 1226px;
            margin: 0 auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }

        .list .list-item {
            width: 18%;
        }

        .list .list-item img {
            width: 100%;
        }

        .list .list-item .goods-price {
            color: red;
            font-size: 14px;
            line-height: 20px;
        }

        .list .list-item .goods-name {
            font-size: 14px;
            line-height: 20px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;

            /* 注：
            -webkit-line-clamp用来限制在一个块元素显示的文本的行数。 为了实现该效果，它须要组合其余的WebKit属性。常见结合属性：
            display: -webkit-box; 必须结合的属性 ，将对象做为弹性伸缩盒子模型显示 。
            -webkit-box-orient 必须结合的属性 ，设置或检索伸缩盒对象的子元素的排列方式 。 */
        }
    </style>
</head>

<body>
    <div class="list">
        <!-- <div class="list-item">
            <a href="">
                <img src="https://img12.360buyimg.com/n7/jfs/t1/11053/22/16472/164875/627c6640E9d621e44/e4e426ad69c699b2.jpg" alt="">
            </a>
            <div class="goods-price">￥2688.00</div>
            <div class="goods-name">【稀缺现货速发】华为手表WATCH GT3 Pro运动智能两周续航电话体温监测潜水</div>
        </div>
        <div class="list-item">
            <a href="">
                <img src="https://img12.360buyimg.com/n7/jfs/t1/11053/22/16472/164875/627c6640E9d621e44/e4e426ad69c699b2.jpg" alt="">
            </a>
            <div class="goods-price">￥2688.00</div>
            <div class="goods-name">【稀缺现货速发】华为手表WATCH GT3 Pro运动智能两周续航电话体温监测潜水</div>
        </div>
        <div class="list-item">
            <a href="">
                <img src="https://img12.360buyimg.com/n7/jfs/t1/11053/22/16472/164875/627c6640E9d621e44/e4e426ad69c699b2.jpg" alt="">
            </a>
            <div class="goods-price">￥2688.00</div>
            <div class="goods-name">【稀缺现货速发】华为手表WATCH GT3 Pro运动智能两周续航电话体温监测潜水</div>
        </div>
        <div class="list-item">
            <a href="">
                <img src="https://img12.360buyimg.com/n7/jfs/t1/11053/22/16472/164875/627c6640E9d621e44/e4e426ad69c699b2.jpg" alt="">
            </a>
            <div class="goods-price">￥2688.00</div>
            <div class="goods-name">【稀缺现货速发】华为手表WATCH GT3 Pro运动智能两周续航电话体温监测潜水</div>
        </div>
        <div class="list-item">
            <a href="">
                <img src="https://img12.360buyimg.com/n7/jfs/t1/11053/22/16472/164875/627c6640E9d621e44/e4e426ad69c699b2.jpg" alt="">
            </a>
            <div class="goods-price">￥2688.00</div>
            <div class="goods-name">【稀缺现货速发】华为手表WATCH GT3 Pro运动智能两周续航电话体温监测潜水</div>
        </div> -->
    </div>
</body>
<script>
    $(function () {

        loadGoods()

        async function loadGoods() {

            var res = await searchAllGoods();
            console.log(res);
            var { status, message, list } = res;

            if (status) {
                if (list.length > 0) {
                    var html = "";
                    list.forEach(({ g_id, g_name, g_price, g_img, g_comment, g_shop }) => {
                        html += `<div class="list-item">
            		                    <a href="./detail.html?gid=${g_id}">
            		                        <img src="${g_img}" alt="">
                                            <div class="goods-price">￥${g_price}</div>
                                            <div class="goods-name">${g_name}</div>
                                        </a>
            		                </div>`;
                    })
                    $(".list").html(html);
                }
            }


        }

    })


</script>

</html>